<template>
    <div class="app-container">
      <el-table v-loading="loading" :data="huishouList" @selection-change="handleSelectionChange">
        <el-table type="selection" width="55" align="center" />
        <el-table-column label="ID" align="center" prop="huishouid" />
        <el-table-column label="药品名称" align="center" prop="huishouname" />
        <el-table-column label="数量" align="center" prop="huishounumber" />
        <el-table-column label="批号" align="center" prop="huishoupihao" />
        <el-table-column label="经办人" align="center" prop="jbr" />
        <el-table-column label="备注" align="center" prop="beizhu" />
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="primary"
              @click="handleDelete(scope.row)"
              v-hasPermi="['warehouse:huishou:remove']"
            >已处理</el-button>
          </template>
        </el-table-column>
      </el-table>
      
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
  
    </div>
  </template>
  
  <script>
  import { listHuishou, delHuishou} from "@/api/warehouse/huishou";
  
  export default {
    name: "Huishou",
    data() {
      return {
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 药品回收表格数据
        huishouList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          huishouname: null,
          huishounumber: null,
          huishoupihao: null,
          jbr: null,
          beizhu: null
        },
        // 表单参数
        form: {},
      };
    },
    created() {
      this.getList();
    },
    methods: {
      /** 查询药品回收列表 */
      getList() {
        this.loading = true;
        listHuishou(this.queryParams).then(response => {
          this.huishouList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
          huishouid: null,
          huishouname: null,
          huishounumber: null,
          huishoupihao: null,
          jbr: null,
          beizhu: null
        };
        this.resetForm("form");
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      /** 删除按钮操作 */
      handleDelete(row) {
        const huishouids = row.huishouname || this.ids;
        this.$modal.confirm('确认处理"'+huishouids+ '"这个药品吗？').then(function() {
          return delHuishou(huishouids);
        }).then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        }).catch(() => {});
      },
    }
  };
  </script>
  